package com.jomoo.scs.controller.product;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.jomoo.scs.dto.product.ProductClassDTO;
import com.jomoo.scs.service.product.ProductClassService;
import com.jomoo.scs.utils.ResultBean;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@Api("产品接口")
@RestController
@RequestMapping("/product")
public class ProductController {
	
	@Autowired
	private ProductClassService productClassService;
	
	@ApiOperation(value="获取产品分类列表", notes="根据上级id(pcnumber)获取品类数据")
	@ApiImplicitParams({@ApiImplicitParam(name = "pnumber", value = "上级分类id", required = true, dataType = "String"),
	@ApiImplicitParam(name = "channel", value = "渠道id", required = true, dataType = "String")})
	@RequestMapping(path="/classlist/get",method=RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
	public ResultBean getClassList(@RequestParam(value="pnumber",required=true)String pnumber,
			@RequestParam(value="channel",required=true)String channel){
		try{
			List<ProductClassDTO> data = productClassService.selectByPcparentnumber(pnumber, channel);
			return ResultBean.success(data);
		}catch (Exception e) {
			return ResultBean.fail(e);
		}
	}
}
